// src/router/index.js
import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import DetailView from '../views/DetailView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView
    },
    {
      path: '/detail/:id', // 路径中包含一个动态参数 :id
      name: 'detail',
      component: DetailView,
      props: true // 将路径参数 :id 作为 props 传递给 DetailView 组件
    }
  ]
})

export default router